mod model;
mod response;
mod logger;
mod config;

mod handler;
mod domain;

use std;
use actix_web::{App, HttpServer, web};
use actix_web::body::MessageBody;
use crate::config::DATABASE_URL;
use crate::config::sql_pool::build_pool;
use crate::handler::{api_handler, CONTEXT, user_handler};
use crate::model::AppState;

#[actix_web::main]
async fn main() -> std::io::Result<()> {
    logger::init();
    CONTEXT.init_database().await;
    println!("🚀 Server started successfully");
    HttpServer::new(move || {
        App::new().app_data(app_data.clone())
            .configure(api_handler::config)
            .configure(user_handler::config)
    })
        .bind(("127.0.0.1", 8099))?
        .run()
        .await
}
